const actions = {
    //登录成功后 保存用户信息 状态
    setInfo({state},userInfo){
       // state.token = userInfo.token
        state.user = userInfo
        console.log(userInfo);
        console.log(123);
        window.localStorage.setItem('tea_user',JSON.stringify(userInfo))
      //  window.localStorage.setItem('tea_token',userInfo.token)
    },
    //刷新页面后，初始话用户状态
    initUserInfo({state}){
        let userInfo = window.localStorage.getItem('tea_user')
        if(userInfo){
            state.user = JSON.parse(userInfo)
         //   state.token = JSON.parse(userInfo).token
        }
    },
    //用户退出后，清除用户状态
    logOut({state}){
        state.user = ""
      //  state.token = ""
        window.localStorage.removeItem('tea_user')
      //  window.localStorage.removeItem('tea_token')
        // $axios.post('/logout',{},{token:true}).then(res=>{
        //     state.user = ""
        //     state.token = ""
        //     window.localStorage.removeItem('tea_user')
        //     window.localStorage.removeItem('tea_token')
        // })
    }
}

export  default actions